package JavaSE.CODE.javaIO;

import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;

public class ObjectOutputStreamDemo {
    public static void main(String[] args) throws Exception {
        //创建对象流
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("D:\\stu.bin"));
        //序列化（写入操作）
        //Student zhangsan = new Student("zhangsan",20);

        List<Student> students = new ArrayList<>();
        students.add(new Student("zhangsan",20));
        students.add(new Student("lisi",100));

        oos.writeObject(students);
        //关闭
        oos.close();





    }
}
